import type { Coupon, CouponDto, CouponPageDto } from '@/models/coupon'
import type { CommonResult, CommonPage } from '@/models/request'
import request, { ContentTypeEnum } from '@/utils/request'
export function fetchList(params: CouponPageDto) {
  return request<CommonPage<Coupon>>({
    url: '/coupon/list',
    method: 'get',
    params: params,
  })
}

export function createCoupon(data: CouponDto) {
  return request<CommonResult>({
    url: '/coupon/create',
    method: 'post',
    data: data,
  })
}

export function getCoupon(id: number) {
  return request<CommonResult<CouponDto>>({
    url: '/coupon/' + id,
    method: 'get',
  })
}

export function updateCoupon(data: CouponDto) {
  return request<CommonResult>({
    url: '/coupon/update/' + data.id,
    method: 'post',
    data: data,
  })
}

export function deleteCoupon(id?: number) {
  return request<CommonResult>({
    url: '/coupon/delete/' + id,
    method: 'post',
    headers: {
      'Content-Type': ContentTypeEnum.form,
    },
  })
}
